/* Copyright (c) 2006, 2009, Carl Burch. License information is located in the
 * com.cburch.logisim.Main source code and at www.cburch.com/logisim/. */
 
package com.cburch.draw.tools;

import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.List;

import javax.swing.Icon;

import com.cburch.draw.canvas.Canvas;
import com.cburch.draw.canvas.CanvasTool;
import com.cburch.draw.model.DrawingAttributeSet;

/**
 * Abstract class that represents methods a tool must have.
 * Examples of extending classes include the <code>LineTool</code>,
 * <code>PolyTool</code>, and the <code>selectTool</code>.
 */
public abstract class AbstractTool extends CanvasTool {
	/**
	 * Returns an array of new instances of all tools.
	 * @param attrs <code>DrawingAttributeSet</code> used to create the tools
	 * @return <code>AbstractTool[]</code> of tools
	 */
    public static AbstractTool[] getTools(DrawingAttributeSet attrs) {
        return new AbstractTool[] {
            new SelectTool(),
            new LineTool(attrs),
            new PolylineTool(attrs),
            new RectangleTool(attrs),
            new RoundRectangleTool(attrs),
            new OvalTool(attrs),
            new PolygonTool(attrs),
        };
    }
    
    /**
     * Returns the <code>Icon</code> associated with the <code>AbstractTool</code>.
     * @return <code>Icon</code>
     */
    public abstract Icon getIcon();
    
    /**
     * Returns a <code>List</code> containing the <code>Attributes</code> associated with the class.
     * @return <code>List</code> of <code>Attributes</code>
     */
    public abstract List getAttributes();
    
    /*TODO delete if still unneeded: other Tool methods used in Logisim 2.0
public abstract String getName();
public abstract String getDisplayName();
public abstract String getDescription();
public Tool cloneTool() { return this; }
public boolean sharesSource(Tool other) { return this == other; }
public void setAttributeSet(AttributeSet attrs) { }
public void paintIcon(ComponentDrawContext c, int x, int y) { }
public String toString() { return getName(); }
*/



    
    //
    // CanvasTool methods
    //
    public abstract Cursor getCursor(Canvas canvas);
    
    public void toolSelected(Canvas canvas) { }
    public void toolDeselected(Canvas canvas) { }
    
    public void mouseMoved(Canvas canvas, MouseEvent e) { }
    public void mousePressed(Canvas canvas, MouseEvent e) { }
    public void mouseDragged(Canvas canvas, MouseEvent e) { }
    public void mouseReleased(Canvas canvas, MouseEvent e) { }
    public void mouseEntered(Canvas canvas, MouseEvent e) { }
    public void mouseExited(Canvas canvas, MouseEvent e) { }

    public void keyPressed(Canvas canvas, KeyEvent e) { }
    public void keyReleased(Canvas canvas, KeyEvent e) { }
    public void keyTyped(Canvas canvas, KeyEvent e) { }
    
    /**
     * Draws the tool. 
     * @param canvas	<code>Canvas</code> to draw the object on
     * @param g			<code>Graphics</code> to draw the object with
     */
    public void draw(Canvas canvas, Graphics g) { }
}
